package com.henme.crm.service.admin.impl;

import com.henme.crm.dao.admin.AuthorityMapper;
import com.henme.crm.entity.admin.Authority;
import com.henme.crm.service.admin.AuthorityService;
import com.henme.crm.util.page.Page;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;



@Service
public class AuthorityServiceImpl implements AuthorityService {
	
	protected static Logger logger =  LoggerFactory.getLogger("service");
	
	@Autowired
	private AuthorityMapper authorityMapper;
	

	public void insertAuthority(Authority authority){
		authorityMapper.insertOne(authority);
	}
	public void updateAuthority(Authority  authority){
		authorityMapper.updateOne(authority);
	}
	public void deleteAuthority(long id){
		authorityMapper.deleteOne(id);
	}
	
	public Authority selectAuthority(long id){
	  return 	authorityMapper.selectOne(id);
	}
	
	public Page<Authority> getAuthorityList(Page<Authority> page){
		List<Authority> result = authorityMapper.findAuthorityPage(page);
		page.setResult(result);
		return page;
	}

	@Override
	public List<Authority> getAllAuthorityList() {
		return authorityMapper.getAllAuthorityList();
	}
	
	@Override
	public List<Authority> getAuthorityListByRoleId(long roleId) {
		return authorityMapper.getAuthorityListByRoleId(roleId);
	}
}